<template>
	<view>
		<view class="main">

			<view class="shuru">
				<text class="shuru_tit t1">广告投放所属等级</text>
				<input type="text" class="shuru_text t1" value="" v-model="adtit" placeholder="请输入广告标题" />
			</view>
			<view class="shuru" v-show="Inv!=2">
				<text class="shuru_tit t1">广告内容</text>
				<input type="text" class="shuru_text t1" value="" v-model="adint" placeholder="请输入广告内容" />
			</view>
			<view class="shuru" v-show="Inv!=2">
				<text class="shuru_tit t1">单条广告定价</text>
				<input type="number" class="shuru_text t1" value="" v-model="adpri" placeholder="请输入广告定价" />
			</view>
			<view class="shuru" v-show="Inv!=2">
				<text class="shuru_tit t1">广告投放所属等级</text>
				<picker @change="bindPickerChange" :range="array" range-key="value" class="shuru_text t1"	style="width: 40%;float: right;">
				<image src="../../static/img/turn.png" mode="heightFix"
					style="height: 4vw;width: auto;display: block;float: right;margin-top: 3vw;margin-left: 2vw;">
				</image>
					<view class="uni-input t1">{{array[index]}}</view>
				</picker>
			</view>
			<!-- <view class="shuru" v-show="Inv!=2">
				<text class="shuru_tit t1">是否需要收集信息</text>
				<view class="shuru_text t1">
					<switch @change="shouji" style="transform:scale(0.7)" color="#F1C75E" :checked="switch1" />
				</view>
			</view>
			<view class="shuru" v-show="Inv!=2">
				<text class="shuru_tit t1">是否需要销售</text>
				<view class="shuru_text t1">
					<switch @change="shouji1" style="transform:scale(0.7)" color="#F1C75E" :checked="switch2" />
				</view>
			</view> -->
			
			<view class="shuru" v-show="Inv!=2">
				<text class="shuru_tit t1" style="width: 60%;">是否需要收集信息/销售</text>
				<picker @change="bindPickerChange1" :range="array1" class="shuru_text" style="width: 40%;float: right;">
				<image src="../../static/img/turn.png" mode="heightFix"
					style="height: 4vw;width: auto;display: block;float: right;margin-top: 3vw;margin-left: 2vw;">
				</image>
					<view class="uni-input t1">{{array1[index1]}}</view>
				</picker>
			</view>
			<view class="shuru" v-show="switch2">
				<text class="shuru_tit t1">产品名称</text>
				<input type="text" class="shuru_text t1" value="" v-model="protit" placeholder="请输入产品名称" />
			</view>
			<view class="shuru" v-show="switch2">
				<text class="shuru_tit t1">产品原价</text>
				<input type="number" class="shuru_text t1" value="" v-model="proopri" placeholder="请输入产品原价" />
			</view>
			<view class="shuru" v-show="switch2">
				<text class="shuru_tit t1">产品现价</text>
				<input type="number" class="shuru_text t1" value="" v-model="pronpri" placeholder="请输入产品现价" />
			</view>
			<view class="shuru" v-show="switch2">
				<text class="shuru_tit t1">店铺名称</text>
				<input type="text" class="shuru_text t1" value="" v-model="dpname" placeholder="请输入店铺名称" />
			</view>
			<view class="shuru" v-show="switch2">
				<text class="shuru_tit t1">店铺地址</text>
				<view class="shuru_text t1" @click="dingwei1" style="position: relative;height: auto;line-height: 6vw;">
					{{adrname1}}
					<!-- <image src="/static/img/turn.png" mode="heightFix" style="height: 4vw; margin-top: 3vw;position: absolute;right: 0;top: 0;background: #fff;">
					</image> -->
				</view>
			</view>
			<view class="baodan_zhu t1" v-show="switch2">
				<view class="baodan_tit1 t1">广告产品介绍图片</view>
				<view class="uni-padding-wrap uni-common-mt baodan_into1" @click="chooseImage1">
				</view>
				<view class="imgi" v-for="(item,index) in proimg" :key="'p'+index">
					<image src="/static/img/clo.png" class="imgdel" @click="delimg(index)"></image>
				<!-- <view class="imgi" v-for="(item,index) in proimg" :key="'p'+index"> -->
					<!-- {{item}} -->
					<image :src="item" mode="widthFix"></image>
				</view>
			</view>
			<!-- <view class="shuru" v-show="Inv==2">
				<text class="shuru_tit t1">链接地址</text>
				<input type="text" class="shuru_text t1" value="" v-model="pri" placeholder="请输入链接地址" />
			</view> -->
			<view class="shuru">
				<text class="shuru_tit t1">选则广告投放位置</text>
				<view class="shuru_text t1" @click="dingwei" style="position: relative;height: auto;line-height: 6vw;">
					{{adrname}}
					<!-- <image src="/static/img/turn.png" mode="heightFix" style="height: 4vw; margin-top: 3vw;position: absolute;right: 0;top: 0;background: #fff;">
					</image> -->
				</view>
			</view>
			<view class="baodan_zhu t1" v-show="Inv==0">
				<view class="baodan_tit1 t1">广告图片</view>
				<view class="uni-padding-wrap uni-common-mt baodan_into" @click="chooseImage">
					<block v-if="imageSrc!=''">
						<image :src="imageSrc" class="image baodan_into_image" mode="widthFix"></image>
					</block>
				</view>
				<!-- <view class="uni-padding-wrap uni-common-mt baodan_into1" @click="chooseImage">
				</view>
				<view class="imgi" v-for="(item,index) in imageSrc" :key="'i'+index">
					<image :src="imageSrc" mode="widthFix"></image>
				</view> -->
			</view>
			<view class="baodan_zhu t1" v-show="Inv==1">
				<view class="baodan_tit t1">广告视频封面图片</view>
				<view class="uni-padding-wrap uni-common-mt baodan_into" @click="chooseImage2">
					<block v-if="videosimg">
						<image :src="videosimg" class="image baodan_into_image" mode="widthFix"></image>
					</block>
				</view>
			</view>

		<!-- 	<view class="baodan_zhu t1" v-show="Inv==1">
				<view class="baodan_tit t1">广告视频</view>
				<video class="baodan_into" :src="videos" style="display: block;float: left;height: 40vw;"></video>
				<view class="uni-padding-wrap uni-common-mt baodan_into" @click="chooseImage3"
					style="border: 1px solid #eee;border-radius: 2vw;margin: 2vw 0;"></view>
			</view> -->
			<view class="baodan_zhu t1" v-show="Inv==1">
				<text class="shuru_tit t1" @click="chooseImage3">广告视频</text>
				<!-- <view class="baodan_tit t1">请上传视频</view> -->
				<view class="shuru_text t1" @click="chooseImage3" >
					<image src="/static/img/shangc.png" mode="heightFix" style="height:7vw;width: 7vw;display: block;float: right; margin-top: 2vw;"> </image>
				</view>
				<view class="uni-padding-wrap uni-common-mt baodan_into">
						<video :src="videos" class="image baodan_into_image" style="height: 40vw;width: 100%; margin: 0;"></video>
						<!-- <image :src="videos" class="image baodan_into_image" mode="widthFix"></image> -->
				</view>
			</view>
			<view class="tuic t2" @click="zhuanru()" style="margin-bottom: 10vw;">确定</view>
		</view>
	</view>
</template>

<script>
	// let mapSearch = weex.requireModule('mapSearch');
	export default {
		data() {
			return {
				Inv: 0,
				array: [{value:'无限',type:'0'}, {value:'省',type:'1'}, {value:'市',type:'2'}, {value:'区',type:'3'}, {value:'街道',type:'4'}, {value:'小区',type:'5'}],
				array1:['否','收集信息','销售'],
				mainid: '',
				imageSrc: '',
				imageSrcid: '',
				videosimg: '',
				videosimgid: '',
				videos: '',
				videosid: '',
				index: 0,
				index1: 0,
				address: '',
				// switch1: false,
				// switch2: false,
				longitude: '',
				latitude: '',
				adrname: '',
				longitude1: '',
				latitude1: '',
				adrname1: '',
				proimg: [],
				proimgid: [],
				pronpri: '',
				proopri: '',
				protit: '',
				adpri: '',
				adint: '',
				adtit: '',
				dpname: '',
				imageSrc1: '',
				imageSrcid1: '',
				videosimg1: '',
				videosimgid1: '',
				videos1: '',
				videosid1: '',
				index1: 0,
				address1: '',
				switch11: 0,
				switch21: 0,
				longitude11: '',
				latitude11: '',
				adrname11: '',
				longitude21: '',
				latitude21: '',
				adrname21: '',
				pronpri1: '',
				proopri1: '',
				protit1: '',
				adpri1: '',
				adint1: '',
				adtit1: '',
				dpname1: '',
				id: '',
				sellPicIdStr:'',
				sellPicIdStr:'',
				checks:true,
				switch1: 0,
				switch2: 0,
			}
		},
		onLoad(options) {
			var _this = this;
			uni.$on("maps", (options) => {
				console.log(options);
				_this.latitude = options.latitude;
				_this.longitude = options.longitude;
				uni.$off('maps')
			})

			_this.id = options.id;
			uni.getStorage({
				key: 'user',
				success: function(res) {
					_this.mainid = res.data.id;
					_this.xq();
				}
			});

		},
		onShow() {
			// this.handleAuthorize()
		},
		methods: {
			delimg(e){
				var list=[];
				var list1=[];
				for(var i=0;i<this.proimgid.length;i++){
					if(i!=e){
						list.push(this.proimgid[i]);
						list1.push(this.proimg[i]);
					}
				}
				this.proimgid=list;
				this.proimg=list1;
			},
// 选择是否加其他链接
bindPickerChange1: function(e) {
				var that = this;
				var ii = e.detail.value;
				that.index1=ii;
				if (ii == 0) {
					that.switch1 = 0;
					that.switch2 = 0;
				} else if (ii == 1) {
					that.switch1 = 1;
					that.switch2 = 0;
				}else{
					that.switch1 = 0;
					that.switch2 = 1;
				}
				console.log(that.switch1,that.switch2);
			},
			bindPickerChange: function(e) {
				this.Inv = e.detail.value
			},

			// 用户授权
			handleAuthorize() {
				const _this = this // 下边this 为undefined
				uni.authorize({
					scope: 'scope.userLocation', // 获取地理信息必填的参数，其它参数见文档
					success(res) {
						_this.getLocationFn()
					},
					// 授权失败
					fail(err) {
						err = err['errMsg']
						uni.showModal({
								title: '温馨提示',
								content: '为精准选择投放位置，请选择授权',
								showCancel: false,
								confirmText: '确认授权'
							})
							// 这里只设置了确认按钮，没有取消按钮
							.then(res => {
								//res ： [null, {cancel: false, confirm: true, errMsg: 'showModal: ok'}]
								if (res[1]['confirm']) { // 点击了确认按钮时
									// 调用下边方法时，会弹出 【使用我的地理位置】界面， 未设置直接返回，还是会走fail授权失败的函数，
									// 还是会弹出上边的温馨提示！！！
									// 如果设置, scope.userLocation: true
									uni.openSetting({
										success(res) {
											// 如果不设置，res结果：
											// {errMsg: "openSetting:ok", authSetting: {scope.userLocation: false}}
											// 如果设置, res结果： 
											// {errMsg: "openSetting:ok", authSetting: {scope.userLocation: true}}
											// console.log('小程序设置界面：', res)
										}
									})
								}
							})
					}
				})
			},
			videoErrorCallback: function(e) {
				uni.showModal({
					content: e.target.errMsg,
					showCancel: false
				})
			},
			dingwei() {
				var that = this;
				uni.chooseLocation({
					success: function(res) {
						console.log('位置名称：' + res.name);
						console.log('详细地址：' + res.address);
						console.log('纬度：' + res.latitude);
						console.log('经度：' + res.longitude);
						that.adrname = res.address;
						that.latitude = res.latitude;
						that.longitude = res.longitude;
					}
				});
			},
			dingwei1() {
				var that = this;
				uni.chooseLocation({
					success: function(res) {
						console.log('位置名称：' + res.name);
						console.log('详细地址：' + res.address);
						console.log('纬度：' + res.latitude);
						console.log('经度：' + res.longitude);
						that.adrname1 = res.address;
						that.latitude1 = res.latitude;
						that.longitude1 = res.longitude;
					}
				});
			},
			// shouji1(e) {
			// 	this.switch2 = e.detail.value
			// 	console.log(this.switch2);
			// },
			// shouji(e) {
			// 	this.switch1 = e.detail.value
			// 	console.log(this.switch1);
			// },
			fuzhi() {
				var that = this;
				uni.setClipboardData({
					data: that.address,
					success: function() {
						uni.showToast({
							title: '复制成功',
							icon: 'success',
							duration: 1000
						})
					}
				});
			},
			chooseImage3: function() {
				var _this = this;
				uni.chooseVideo({
					count: 1,
					sourceType: ['camera', 'album'],
					success: function(res) {
						var src = res.tempFilePath;
						console.log(res);
						var uploadTask = uni.uploadFile({
							url: getApp().globalData.url + 'file/uploadsVideo',
							filePath: src,
							name: 'file',
							fileType: 'video',
							formData: {
								// 'files':tempFilePaths[i],
							},
							success: function(uploadFileRes) {
								console.log(uploadFileRes);
								if (uploadFileRes.statusCode == '200') {
									var datamain = JSON.parse(uploadFileRes.data);
									_this.videos = datamain.data.url;
									_this.videosid = datamain.data.id;

								}
							}
						});

						// uploadTask.onProgressUpdate(function(res) {});
					},
					error: function(e) {
						console.log(e);
						uni.showToast({
							title: '上传失败',
							icon: 'none',
							duration: 1000
						})
					}
				});
			},
			chooseImage2: function() {
				var _this = this;
				uni.chooseImage({
					count: 1,
					sizeType: ['compressed'],
					sourceType: ['album'],
					success: function(res) {
						var tempFilePaths = res.tempFilePaths;
						var uploadTask = uni.uploadFile({
							url: getApp().globalData.url + 'file/uploads',
							filePath: tempFilePaths[0],
							name: 'files',
							formData: {
								// 'files':tempFilePaths[i],
							},
							success: function(uploadFileRes) {
								var datamain = JSON.parse(uploadFileRes.data);
								console.log(datamain);
								var url = datamain.data[0].url;
								_this.videosimg = url;
								// _this.videosimg='/static/img/logo.png';
								_this.videosimgid = datamain.data[0].id;
								console.log(url);
							}
						});
					},
					error: function(e) {
						console.log(e);
						uni.showToast({
							title: '上传失败',
							icon: 'none',
							duration: 1000
						})
					}
				});

			},
			chooseImage1: function() {
				var _this = this;
				uni.chooseImage({
					count: 9,
					sizeType: ['compressed'],
					sourceType: ['album'],
					success: function(res) {
						var len = res.tempFilePaths.length;
						console.log(res.tempFilePaths);
						for (var i = 0; i < len; i++) {
							// _this.proimg = res.tempFilePaths[0];
							var tempFilePaths = res.tempFilePaths;
							// console.log(_this.token);
							var uploadTask = uni.uploadFile({
								url: getApp().globalData.url + 'file/uploads',
								filePath: tempFilePaths[i],
								name: 'files',
								formData: {
									// 'files':tempFilePaths[i],
								},
								success: function(uploadFileRes) {
									var datamain = JSON.parse(uploadFileRes.data);
									_this.proimg.push(datamain.data[0].url);
									console.log(_this.proimgid);
									_this.proimgid.push(datamain.data[0].id);
									console.log(_this.proimgid);
								}
							});

							uploadTask.onProgressUpdate(function(res) {});
						}


					},
					error: function(e) {
						console.log(e);
						uni.showToast({
							title: '上传失败',
							icon: 'none',
							duration: 1000
						})
					}
				});

			},
			chooseImage: function() {
				var _this = this;
				uni.chooseImage({
					count: 1,
					sizeType: ['compressed'],
					sourceType: ['album'],
					success: function(res) {
						console.log(res);
						var tempFilePaths = res.tempFilePaths;
						var uploadTask = uni.uploadFile({
							url: getApp().globalData.url + 'file/uploads',
							filePath: tempFilePaths[0],
							name: 'files',
							formData: {
								// 'files':tempFilePaths[i],
							},
							success: function(uploadFileRes) {
								var datamain = JSON.parse(uploadFileRes.data);
								console.log(datamain);
								var url = datamain.data[0].url;
								_this.imageSrc = url;
								// _this.imageSrc = '/static/img/logo.png';
								_this.imageSrcid = datamain.data[0].id;
								console.log(url);
							}
						});

					},
					error: function(e) {
						console.log(e);
						uni.showToast({
							title: '上传失败',
							icon: 'none',
							duration: 1000
						})
					}
				});

			},


			// 地理位置
			haddress(longitude, latitude, ke) {
				var that = this;
				var point = new plus.maps.Point(longitude, latitude);
				plus.maps.Map.reverseGeocode(point, {},
					function(res) {
						console.log(res.address);
						if (ke == 1) {
							that.adrname1 = res.address; //店铺位置
						} else {
							that.adrname = res.address; //广告投放位置
						}
					},
					function(e) {});
				// var point = {
				// 	latitude: latitude,
				// 	longitude: longitude
				// };
				// mapSearch.reverseGeocode({
				// 	point
				// }, ret => {
				// 	if (ke == 1) {
				// 		that.adrname1 = ret.address; //店铺位置
				// 	} else {
				// 		that.adrname = ret.address; //广告投放位置
				// 	}
				// })

			},
			tup(id, ke) {
				var _this = this;
				uni.request({
					header: {
						'Content-Type': 'application/x-www-form-urlencoded', //自定义请求头信息
					},
					url: getApp().globalData.url + 'file/getFileUrl/' + id, //仅为示例，并非真实接口地址。
					method: 'POST',
					data: {
						id: id

					},
					success: (res) => {
						console.log(res);
						uni.hideLoading(); //关闭加载动画
						if (res.data.status == '200') {
							if (ke == 1) {
								if (_this.Inv == 1) {
									// console.log(res.data.data);	
									_this.videos = res.data.data; //产品图片
									console.log(_this.videos);
								} else {
									_this.imageSrc = res.data.data; //产品图片
								}
							} else {
								_this.proimg.push(res.data.data); //广告图片		
								console.log(_this.proimg);
							}
						}
					},
					fail: (error) => {
						// this.checks = true
						console.log(error)
					}
				});
			},

			xq() {
				var _this = this;
				uni.request({
					header: {
						'Content-Type': 'application/json', //自定义请求头信息
					},
					url: getApp().globalData.url + 'advertising/getMyAdvertising', //仅为示例，并非真实接口地址。
					method: 'POST',
					data: {
						id: _this.id, //	单条广告定价（分）\n tip:定价后不可修改		true							integer
						belongId: _this.mainid, //	所属用户(mainId)		true							string

					},
					success: (res) => {
						console.log(res);
						uni.hideLoading(); //关闭加载动画
						if (res.data.status == '200') {

							_this.Inv = res.data.data.showType;
							if (res.data.data.showType == 1) {
								_this.videosid = res.data.data.fileId;
							} else {
								_this.imageSrcid = res.data.data.fileId;
							}
							_this.videosimg = res.data.data.thumbnailUrl;
							// if (res.data.data.sell == 1) {
							// 	_this.switch2 = true;
							// 	_this.switch21 = true;
							// } else {
							// 	_this.switch2 = false;
							// 	_this.switch21 = false;
							// }
							console.log(res.data.data.collect,res.data.data.sell);
							if (res.data.data.collect == 1) {
								_this.index1 =1; 
							} else if (res.data.data.sell == 1) {
								_this.index1 =2; 
							}else{
							_this.index1 =0; 
							}
							// console.log(_this.index1);
								_this.switch1 = res.data.data.collect;
								_this.switch11 = res.data.data.collect;
								_this.switch2 = res.data.data.sell;
								_this.switch21 = res.data.data.sell;
							_this.longitude = res.data.data.longitude;
							_this.longitude11 = res.data.data.longitude;
							_this.latitude = res.data.data.latitude;
							_this.latitude11 = res.data.data.latitude;
							_this.longitude1 = res.data.data.merchantLongitude;
							_this.longitude21 = res.data.data.merchantLongitude;
							_this.latitude1 = res.data.data.merchantLatitude;
							_this.latitude21 = res.data.data.merchantLatitude;
							_this.dpname = res.data.data.merchantName;
							_this.dpname1 = res.data.data.merchantName;
							_this.pronpri = res.data.data.sellAmount;
							_this.pronpri1 = res.data.data.sellAmount;
							_this.proopri = res.data.data.sellOriginalAmount/100;
							_this.proopri1 = res.data.data.sellOriginalAmount/100;
							_this.protit = res.data.data.sellName;
							_this.protit1 = res.data.data.sellName;
							_this.adpri = res.data.data.amount;
							_this.adpri1 = res.data.data.amount;
							_this.adint = res.data.data.content;
							_this.adint1 = res.data.data.content;
							_this.adtit = res.data.data.title;
							_this.adtit1 = res.data.data.title;
							_this.sellPicIdStr = res.data.data.sellPicIdStr;
							_this.sellPicIdStr1 = res.data.data.sellPicIdStr;
							_this.tup(res.data.data.fileId, 1);
							// console.log(res.data.data.longitude, res.data.data.latitude);
							_this.haddress(res.data.data.longitude, res.data.data.latitude, 1);
							_this.haddress(res.data.data.merchantLongitude, res.data.data.merchantLatitude, 0);
							if (res.data.data.sellPicIdStr) {
								var propic = res.data.data.sellPicIdStr.split(",");
								for (var i = 0; i < propic.length; i++) {
									_this.proimgid.push(propic[i]);
									// console.log(_this.proimgid);
									_this.tup(propic[i], 2);
								}
							}
						}
					},
					fail: (error) => {
						// this.checks = true
						console.log(error)
					}
				});
			},
			zhuanru() {
				var _this = this;
				if (_this.checks === false) {
					return false
				}
				// setTimeout(function(){
				// 	_this.checks = true;
				// },5000);
				var sellPicIdStr = '';
				for (var i = 0; i < _this.proimgid.length; i++) {
					if (sellPicIdStr == '') {
						sellPicIdStr = _this.proimgid[i];
					} else {
						sellPicIdStr = sellPicIdStr + ',' + _this.proimgid[i];
					}
				}
				if (_this.adtit == _this.adtit1&_this.sellPicIdStr == sellPicIdStr & _this.switch1 == _this.switch11 & _this.switch2 == _this.switch21 & _this.dpname == _this.dpname1 & _this.longitude1 == _this.longitude21 & _this.latitude1 == _this.latitude21 & _this.latitude == _this.latitude11 & _this.longitude == _this.longitude11& _this.adint == _this.adint1 & _this.adpri == _this.adpri1 & _this.proopri == _this.proopri1 & _this.protit == _this.protit1 & _this.pronpri == _this.pronpri1 ) {
					uni.showToast({
						title: '内容无任何修改',
						icon: 'none',
						duration: 2000
					});
					return false
				}
				// console.log(_this.latitude, _this.latitude11, _this.longitude, _this.longitude11, _this.longitude21, _this.longitude1, _this.dpname1,_this.dpname);
				if (!_this.adtit) {
					uni.showToast({
						title: '请输入广告标题',
						icon: 'none',
						duration: 2000
					});
					return false
				}
				if (!_this.adint) {
					uni.showToast({
						title: '请输入广告内容',
						icon: 'none',
						duration: 2000
					});
					return false
				}
				if (!_this.adpri) {
					uni.showToast({
						title: '请输入单条广告定价',
						icon: 'none',
						duration: 2000
					});
					return false
				}
				if (_this.switch2 == true) {
					if (!_this.protit) {
						uni.showToast({
							title: '请输入产品名称',
							icon: 'none',
							duration: 2000
						});
						return false
					}
					if (!_this.proopri) {
						uni.showToast({
							title: '请输入产品原价',
							icon: 'none',
							duration: 2000
						});
						return false
					}
					if (!_this.pronpri) {
						uni.showToast({
							title: '请输入产品现价',
							icon: 'none',
							duration: 2000
						});
						return false
					}
					if (!_this.dpname) {
						uni.showToast({
							title: '请输入店铺名称',
							icon: 'none',
							duration: 2000
						});
						return false
					}
					if (!_this.longitude1) {
						uni.showToast({
							title: '请选择店铺地址',
							icon: 'none',
							duration: 2000
						});
						return false
					}
					if (_this.proimg.length <=0) {
						uni.showToast({
							title: '请上传产品介绍图片',
							icon: 'none',
							duration: 2000
						});
						return false
					}
				}
				if (!_this.longitude) {
					uni.showToast({
						title: '请选择广告投放位置',
						icon: 'none',
						duration: 2000
					});
					return false
				}
				var fileId = '';
				if (_this.Inv == 0) {
					if (!_this.imageSrcid) {
						uni.showToast({
							title: '请上传广告图片',
							icon: 'none',
							duration: 2000
						});
						return false
					}
					fileId = _this.imageSrcid;
					_this.videosimg = _this.imageSrc;
				} else {
					if (!_this.videosimg) {
						uni.showToast({
							title: '请上传视频封面图片',
							icon: 'none',
							duration: 2000
						});
						return false
					}
					if (!_this.videos) {
						uni.showToast({
							title: '请上传视频',
							icon: 'none',
							duration: 2000
						});
						return false
					}
					fileId = _this.videosid;
				}
				// var swi1 = 0;
				// if (_this.switch1 == true) {
				// 	swi1 = 1;
				// } else {
				// 	swi1 = 0
				// }
				// var swi2 = 0;
				// if (_this.switch2 == true) {
				// 	swi2 = 1;
				// } else {
				// 	swi2 = 0
				// }
_this.checks = false;
				uni.showLoading();
				uni.request({
					header: {
						'Content-Type': 'application/json', //自定义请求头信息
					},
					url: getApp().globalData.url + 'advertising/saveOrUpdate', //仅为示例，并非真实接口地址。
					method: 'POST',
					data: {
						amount: _this.adpri, //	单条广告定价（分）\n tip:定价后不可修改		true							integer
						belongId: _this.mainid, //	所属用户(mainId)		true							string
						collect: _this.switch1, //	是否需要收集信息（0：否；1：是）		true							integer
						content: _this.adint, //	文本内容		true							string
						fileId: fileId, //	文件ID		true							string
						latitude: _this.latitude, //	纬度		true							string
						longitude: _this.longitude, //	经度		true							string
						sell: _this.switch2, //	是否需要销售（0：否；1：是）		true							integer
						showType: _this.Inv, //	展示类型（0:图片；1:视频：2:h5）		true							integer
						thumbnailUrl: _this.videosimg, //	缩略图Url
						title: _this.adtit, //	标题		true							string
						SaveOrUpdate: '', //	paramsMap	body	true							SaveOrUpdate						SaveOrUpdate
						id: _this.id, //	修改必填/新增不填		false							string
						merchantName: _this.dpname, //	店铺名称		false							string
						radius: '', //	展示范围(暂不填写)		false							integer
						merchantLatitude: _this.latitude1,
						merchantLongitude: _this.longitude1, //	产品现价		false							string
						sellName: _this.protit,
						sellAmount: _this.pronpri, //	产品现价		false							string
						sellOriginalAmount: _this.proopri, //	产品原价		false							string
						sellPicIdStr: sellPicIdStr, //	销售商品说明图（用','分隔；需要销售产品时必填）
						url: ''
					},
					success: (res) => {
						console.log(res);
						uni.hideLoading(); //关闭加载动画
						this.checks = true
						if (res.data.status == '200') {

							uni.showToast({
								title: '修改成功，等待审核通过。',
								icon: 'none',
								duration: 2000
							});
							setTimeout(function(){
							uni.navigateBack({
								delta: 1
							})
							},2000)
						}
					},
					fail: (error) => {
						uni.hideLoading();
						this.checks = true
						console.log(error)
					}
				});
			}
		}
	}
</script>

<style>
	.inv-h-w {
		background-color: #FFFFFF;
		height: 10vw;
		display: flex;
		width: 100%;
		position: fixed;
		top: 0;
		left: 0;
		z-index: 999;
	}

	.inv-h {
		font-size: 0.8rem;
		flex: 1;
		text-align: center;
		color: #333;
		height: 10vw;
		line-height: 10vw;
	}

	.inv-h-se {
		color: #F1C75E;
		border-bottom: 1vw solid #F1C75E;
	}

	.login_main_li_yzm {
		width: auto;
		height: 8vw;
		display: block;
		float: right;
		background: #fcbe16;
		padding: 0 3vw;
		line-height: 8vw;
		border-radius: 4vw;
	}

	.shuru {
		width: 100%;
		height: auto;
		display: block;
		float: left;
		border-radius: 2vw;
		overflow: hidden;
		padding: 2vw 4vw;
		background: #fff;
		margin-top: 4vw;
		box-shadow: 0px 0px 1vw #ddd;
	}

	.shuru_tit {
		width: 45%;
		height: 10vw;
		line-height: 10vw;
		display: block;
		float: left;
	}

	.shuru_text {
		width: 55%;
		height: 10vw;
		line-height: 10vw;
		display: block;
		float: right;
		text-align: right;
	}

	select.shuru_text {
		border: none;
	}



	.baodan_zhu {
		width: 100%;
		height: auto;
		display: block;
		float: left;
		margin: 2vw 0;
		background: #fff;
		border-radius: 2vw;
		padding: 4vw;
		box-shadow: 0px 0px 1vw #ccc;
		margin-top: 4vw;
	}

	.baodan_tit {
		width: 100%;
		height: 8vw;
		line-height: 8vw;
		display: block;
		float: left;
		text-align: center;
	}

	.baodan_tit1 {
		width: 100%;
		height: 8vw;
		line-height: 8vw;
		display: block;
		float: left;
	}

	.baodan_into {
		width: 100%;
		height: auto;
		display: block;
		float: left;
		line-height: 7vw;
		display: block;
		float: left;
		min-height: 40vw;
		background: url(../../static/img/jiaa.png) no-repeat center;
	}

	.baodan_into1 {
		width: 30%;
		height: 24vw;
		display: block;
		float: left;
		line-height: 7vw;
		display: block;
		float: left;
		background: url(../../static/img/jiaa.png) no-repeat center;
		border: 1px solid #eee;
		border-radius: 2vw;
		margin: 2vw 1.6%;
	}

	.imgi {
		width: 30%;
		height: 24vw;
		display: block;
		float: left;
		border: 1px solid #eee;
		margin: 2vw 1.6%;
		border-radius: 2vw;
		overflow: hidden;
		position: relative;
	}

	.imgi image {
		
		width: 100%;
		height: auto;
	}

	.baodan_into_image {
		width: 100%;
		height: auto;
		display: block;
		float: left;
		margin: 0;
	}

	.bai {
		width: 100%;
		height: 12vw;
		display: block;
		float: left;
	}
	.imgi image.imgdel{width: 6vw;height: 6vw;display: block;position:absolute;top: 0;right: 0;padding: 1vw;background: url(../../static/img/bg.png) repeat;z-index: 9;float: right;border-radius: 0 0 0 2vw;}
</style>
